From c4b6b9959328b4d8170b4de82f4dae5a662c5d2b Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Tue, 17 Jun 2014 12:16:51 +0000 Subject: [PATCH] fix whitespace related potential loss of element text in gpx reader. --- gpsbabel/gpx.cc | 17 +- gpsbabel/reference/earth-gc.kml | 322 ++++++++++++++++---------------- 2 files changed, 168 insertions(+), 171 deletions(-) diff --git a/gpsbabel/gpx.cc b/gpsbabel/gpx.cc index aedd74679..5b948ade4 100644 --- a/gpsbabel/gpx.cc +++ b/gpsbabel/gpx.cc @@ -865,7 +865,11 @@ gpx_end(const QString& el) static QDateTime gc_log_date; tag_type tag; + // Remove leading, trailing whitespace. + cdatastr = cdatastr.trimmed(); + tag = get_tag(current_tag, &passthrough); + switch (tag) { /* * First, the tags that are file-global. @@ -922,7 +926,7 @@ gpx_end(const QString& el) wpt_tmp->AllocGCData()->diff = x * 10; break; case tt_cache_hint: - wpt_tmp->AllocGCData()->hint = cdatastr.trimmed(); + wpt_tmp->AllocGCData()->hint = cdatastr; break; case tt_cache_desc_long: { geocache_data* gc_data = wpt_tmp->AllocGCData(); @@ -930,7 +934,7 @@ gpx_end(const QString& el) // FIXME: Forcing a premature conversion here saves 4% on GPX read times // on large PQs. Once cdatastrp becomes real QString this is just (minimal) // overhead. - gc_data->desc_long.utfstring = QString(cdatastr).trimmed(); + gc_data->desc_long.utfstring = QString(cdatastr); } break; case tt_cache_desc_short: @@ -1132,10 +1136,10 @@ gpx_end(const QString& el) link_url = QString(); break; case tt_wpttype_link_text: - link_text = cdatastr.trimmed(); + link_text = cdatastr; break; case tt_wpttype_link_type: - link_type = cdatastr.trimmed(); + link_type = cdatastr; break; case tt_unknown: end_something_else(); @@ -1156,7 +1160,7 @@ gpx_cdata(const QString& s) { QString* cdata; xml_tag* tmp_tag; - cdatastr = s; + cdatastr += s; if (!cur_tag) { return; @@ -1171,7 +1175,7 @@ gpx_cdata(const QString& s) } else { cdata = &(cur_tag->cdata); } - *cdata = cdatastr; + *cdata = cdatastr.trimmed(); } static void @@ -1259,6 +1263,7 @@ gpx_read(void) case QXmlStreamReader::EndElement: gpx_end(reader->qualifiedName().toString()); current_tag.chop(reader->qualifiedName().length() + 1); + cdatastr.clear(); break; case QXmlStreamReader::Characters: diff --git a/gpsbabel/reference/earth-gc.kml b/gpsbabel/reference/earth-gc.kml index b2f5c92c2..ae0d2bb11 100644 --- a/gpsbabel/reference/earth-gc.kml +++ b/gpsbabel/reference/earth-gc.kml @@ -11,7 +11,7 @@ 41.027500 2109328.437865 - + - + @@ -136,81 +136,81 @@ - - - - - - - - -
- - -
- - $[gc_num] $[gc_name] - a $[gc_type],
on $[gc_placed] by $[gc_placer]
- Difficulty: $[gc_diff] -  Terrain: $[gc_terr]
- Size: $[gc_cont_icon] ($[gc_cont_icon])
-

$[gc_issues] - $[gc_short_desc] - $[gc_long_desc] -

-
- - $[gc_num] $[gc_name] - a $[gc_type],
on $[gc_placed] by $[gc_placer]
- Difficulty: $[gc_diff] -  Terrain: $[gc_terr]
- Size: $[gc_cont_icon] ($[gc_cont_icon])
- $[gc_logs] -
-
- - $[gc_num] $[gc_name] - a $[gc_type],
on $[gc_placed] by $[gc_placer]
- Difficulty: $[gc_diff] -  Terrain: $[gc_terr]
- Size: $[gc_cont_icon] ($[gc_cont_icon])
-

Extra Maps

-
-
- - + + + + + + + + +
+ + +
+ +$[gc_num] $[gc_name] +a $[gc_type],
on $[gc_placed] by $[gc_placer]
+Difficulty: $[gc_diff] + Terrain: $[gc_terr]
+Size: $[gc_cont_icon] ($[gc_cont_icon])
+

$[gc_issues] + $[gc_short_desc] + $[gc_long_desc] +

+
+ +$[gc_num] $[gc_name] +a $[gc_type],
on $[gc_placed] by $[gc_placer]
+Difficulty: $[gc_diff] + Terrain: $[gc_terr]
+Size: $[gc_cont_icon] ($[gc_cont_icon])
+ $[gc_logs] +
+
+ +$[gc_num] $[gc_name] +a $[gc_type],
on $[gc_placed] by $[gc_placer]
+Difficulty: $[gc_diff] + Terrain: $[gc_terr]
+Size: $[gc_cont_icon] ($[gc_cont_icon])
+

Extra Maps

+
+
+ + ]]>
@@ -229,7 +229,7 @@ - + 2002-08-15T07:00:00Z #geocache